﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using FirstFloor.Documents.Pdf.Functions;

namespace FirstFloor.Documents.Pdf.ColorSpaces
{
    /// <summary>
    /// Represents the Separation color space.
    /// </summary>
    internal class Separation
        : ColorSpace
    {
        private ColorSpace alternateSpace;
        private Function function;

        /// <summary>
        /// Initializes a new instance of the <see cref="Separation"/> class.
        /// </summary>
        /// <param name="alternateSpace">The alternate space.</param>
        /// <param name="function">The function.</param>
        public Separation(ColorSpace alternateSpace, Function function)
        {
            this.alternateSpace = alternateSpace;
            this.function = function;

            this.Name = "Separation";
            this.DefaultColor = new double[] { 1 };
        }

        /// <summary>
        /// Converts specified value to the XYZ color space.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <returns></returns>
        public override ColorPoint ToXYZ(double[] values)
        {
            var result = this.function.Execute(values);
            return this.alternateSpace.ToXYZ(result);
        }
    }
}
